#ifndef SYSTEMTRAYICON_H
#define SYSTEMTRAYICON_H

#include <QSystemTrayIcon>
#include <QIcon>
#include <QWidget>
#include <QObject>
#include <QEvent>
#include <QDebug>


class SystemTrayIcon : public QSystemTrayIcon {
        Q_OBJECT

    public:
		SystemTrayIcon(const QIcon &icon, QObject *parent = 0) : QSystemTrayIcon(icon, parent) {
        }

        // all next files are lines in tooltip
        // second item of list should be title
        // first item of list should be path to icon
		void setToolTip(QStringList &list) {
#if defined(Q_WS_X11)
            QString html = "<div style='color: #fff;height: 50px; font-weight: bold; margin-bottom: 5px;'>";
            html += tr("<img src='%1'/> %2</div>").arg(list.at(0), list.at(1));
            for (int i = 2; i < list.size(); i++) {
                html += "<div style='vertical-align: baseline; height: 18px;'>";
                html += list.at(i);
                html += "</div>";
            }
#else
            list.takeFirst();
            QString html = list.join("\n");
#endif
            setToolTip(html);
        }

        void setToolTip(const QString &tip) {
            QSystemTrayIcon::setToolTip(tip);
        }

    protected:
        bool event(QEvent *e) {
            if (e->HoverEnter)
                emit trayHovered();
            e->accept();
            return QSystemTrayIcon::event(e);
        }


    signals:
        void trayHovered();

};


#endif // SYSTEMTRAYICON_H
